// 将 dist 目录下，weapp.qrcode.esm.js 复制到项目目录中
import drawQrcode from '../../utils/weapp.qrcode.esm.js'
import WxParse from "../../template/wxParse/wxParse.js"

Page({
  data: {
    poster: 'https://y.qq.com/music/photo_new/T002R300x300M000002Qd8Pw45wkox_1.jpg?max_age=2592000',
    name: '山鬼',
    author: '胡萝卜先生173',
    src: 'http://dl.stream.qqmusic.qq.com/C4000022wXjH0Xq4mN.m4a?guid=6093994736&vkey=E5C8077660EED364CDC780F09406E4824F2F7A845A7C5C5392ED69267A0240150DD9EAAE147CB3201921AF833B12FADA75F8187D90F87431&uin=&fromtag=66',
    msg:"https://github.com/yingye",
    html:`<div>
            <h1>第一张图片</h1>
            <p>端牢饭碗</p>
            <img src="../../assets/mimi.jpeg" alt="">
            <h1>第二张图片</h1>
            <b>无障碍设施</b>
            <img src="../../assets/doudou.jpeg" alt="">
          </div>`
  },
  createCode(){
    if(!this.data.msg){
      return
    }
    drawQrcode({
      width: 200,
      height: 200,
      canvasId: 'myQrcode',
      // ctx: wx.createCanvasContext('myQrcode'),
      text: this.data.msg,
      // v1.0.0+版本支持在二维码上绘制图片
      image: {
        imageResource: '../../assets/miao.jpg',
        dx: 70,
        dy: 70,
        dWidth: 60,
        dHeight: 60,
      },
      background:"#adf"
    })
  },
  onLoad:function(){
    this.createCode()
    const self = this
    WxParse.wxParse('article', 'html', self.data.html, self, 5);
  },
  onReady: function (e) {
    // 使用 wx.createAudioContext 获取 audio 上下文 context
    this.audioCtx = wx.createAudioContext('myAudio')
  },
  audioPlay: function () {
    this.audioCtx.play()
  },
  audioPause: function () {
    this.audioCtx.pause()
  },
  audio14: function () {
    this.audioCtx.seek(14)
  },
  audioStart: function () {
    this.audioCtx.seek(0)
  },
  toCurrentPlay(event){
    console.log(event)
    wx.navigateTo({
      url:"./play"
    })
  },
})